package com.sm.activity.controller;


import com.sm.activity.service.ActivityOperService;
import com.sm.tool.entity.dto.ActivityDetails;
import com.sm.tool.entity.request.AddActivityRequest;
import com.sm.tool.entity.request.AddTicketsRequest;
import com.sm.tool.entity.request.PageInfo;
import com.sm.tool.entity.request.ParticipateaActivityRequest;
import com.sm.tool.entity.response.ReturnData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("api/v1/oper")
@Api(tags = "活动相关操作Api", value = "活动相关操作Api",produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class ActivityOperController {

    @Autowired
    private ActivityOperService activityOperService;

    @ApiOperation(value = "添加活动")
    @PostMapping("/add_activity")
    public ReturnData addActivity(
            @RequestHeader
            @ApiParam("管理员令牌") String adminToken,
            @Validated @RequestBody AddActivityRequest addActivityRequest
    ){
        return activityOperService.addActivity(addActivityRequest);
    }


    @ApiOperation(value = "查看当前活动列表")
    @PostMapping("/query_activitys")
    public ReturnData<List<ActivityDetails>>  queryActivitys(
          @RequestBody  PageInfo pageInfo
    ){
        return activityOperService.queryActivitys(pageInfo);
    }

    @ApiOperation(value = "用户参加活动（领取优惠券）")
    @PostMapping("/participatea_activitys")
    public ReturnData participateaActivity(
            @RequestHeader
            @ApiParam("用户令牌") String token,
            @Validated @RequestBody ParticipateaActivityRequest participateaActivityRequest
    ){
        return activityOperService.participateaActivity(token,participateaActivityRequest);
    }

}
